home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: fred@genesis.demon.co.uk (Lawrence Kirby)
- Newsgroups: comp.lang.c.moderated,comp.std.c
- Subject: Integral promotion.
- Date: 21 Feb 1996 09:31:02 -0600
- Organization: none
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4gfdrm$2vs@solutions.solon.com>
- Reply-To: fred@genesis.demon.co.uk
- NNTP-Posting-Host: solutions.solon.com
- X-Mailer: Demon Internet Simple News v1.27
-
- In article <4g55fl$avl@solutions.solon.com> msb@sq.com writes:
-
- > > > short test(short x1, short x2) {
- > > > short result;
- > > > result = x1 + x2;
- > >
- > > The addition operator "+" converts your short operands to ints.
- >
- > No, just using their values does that. The operator + never sees
- > operands narrower than int. In the statement
- > x1;
- > the short is converted to int before being discarded.
-
- This does however beg a question regarding the standard. Take the
- >> or << operators. In 6.3.7 we have:
-
- "Constraints
-
- Each of the operands shall have integral type
-
- Semantics
-
- The integral promotions are performed on each of the operands..."
-
- If the operator never sees operands narrower than int then this sentence
- is pointless.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-